using System;
using System.Collections.Generic;
using System.Text;
using Blazing.BusinessObjects.Cms;

using NUnit.Framework;
using TestClass = NUnit.Framework.TestFixtureAttribute;
using TestMethod = NUnit.Framework.TestAttribute;
using TestInitialize = NUnit.Framework.SetUpAttribute;
using TestCleanup = NUnit.Framework.TearDownAttribute;
using ClassInitialize = NUnit.Framework.TestFixtureSetUpAttribute;
using ClassCleanup = NUnit.Framework.TestFixtureTearDownAttribute;


namespace BusinessObjectTests
{
    [TestClass]
    public class MenuTests : NHibernateInMemoryTestFixtureBase
    {
        private void CheckValues(Menu obj, Menu newObj)
        {
            Assert.AreEqual(obj.ID, newObj.ID);
            Assert.AreEqual(obj.Name, newObj.Name);
            Assert.AreEqual(obj.Prefix, newObj.Prefix);
            Assert.AreEqual(obj.MenuType.ID, newObj.MenuType.ID);
            Assert.AreEqual(obj.Site.ID, newObj.Site.ID);
            Assert.AreEqual(obj.RowStamp, newObj.RowStamp);
        }

        [TestMethod]
        public void CreateMenu()
        {
            Menu obj = BusinessObjectFactory.CreateAndFillMenu();

            MenuType type = BusinessObjectFactory.CreateAndFillMenuType();
            type.Save();
            Site site = BusinessObjectFactory.CreateAndFillSite();
            site.Save();

            obj.MenuType = type;
            obj.Site = site;

            obj.Save();
            Menu obj2 = Menu.Load(obj.ID);

            CheckValues(obj, obj2);

            obj.Delete();
            obj.Save();

            type.Delete();
            type.Save();
            site.Delete();
            site.Save();
        }
    }
}
